<style lang="scss" scoped>
  @import 'src/styles/vars';
  @import 'src/styles/mixins';
  @import 'src/styles/index';
  .content {
    height: 100%;
    overflow: auto;
    .title {
      color: #de605b;
      font-size: 50px;
      text-align: center;
    }
  }
</style>
<template>
  <div class="content">
    <div class="l-headerTop">
      <div class="l-inner clearfix">
          <span class="fl">
            <i class="icon icon_index01"></i>
            <i class="font">政府合作</i>
            <div class="clear"></div>
          </span>
        <span class="fl">
            <i class="icon icon_index02"></i>
            <i class="font">城市代理</i>
            <div class="clear"></div>
        </span>
        <span class="fl">
            <i class="icon icon_index03"></i>
            <i class="font">手机微职</i>
            <div class="clear"></div>
        </span>
        <div class="fr" v-if="!isLogin">
          <a class="font" @click="toLogin()">登录</a>
          <b>|</b>
          <a class="font" @click="toRegister()">注册</a>
          <!--<b>|</b>-->
          <!--<a class="font" @click="toCompany()">企业用户入口</a>-->
          <div class="clear"></div>
        </div>
        <div class="fr" v-if="isLogin">
          <i class="font" @click="jumpCenter(isLoginType)" v-if="isLoginType == 1" style="cursor: pointer">欢迎登录： {{currentUserInfo.realName}}&nbsp;[<a class="exit" style="color: #ccc;" href="/userCenter">&nbsp;个人中心&nbsp;</a>] &emsp;</i>
          <i class="font" @click="jumpCenter(isLoginType)" v-if="isLoginType == 2" style="cursor: pointer">欢迎登录： {{currentUserInfo.realName}}&nbsp;[<a class="exit" style="color: #ccc;" href="/company">&nbsp;企业中心&nbsp;</a>] &emsp;</i>
          <a class="exit" @click="loginOut()">注销</a>
          <div class="clear"></div>
        </div>
      </div>
    </div>
    <div class="l-header">
      <div class="l-inner clearfix">
        <div class="logo fl">
          <img src="/static/images/web/index/logo.png" width="74" height="78" alt="微职">
          <i>全国站</i>
          <a href="">[切换城市]</a>
        </div>
        <div class="l-nav fr">
          <a href="/home" class="cur">首页</a>
          <a>地图招聘</a>
          <a>线上招聘会</a>
          <a>热点活动</a>
          <a>人才库</a>
          <a>微资讯</a>
          <div class="clear"></div>
        </div>
        <div class="clear"></div>
      </div>
    </div>
    <!--<div class="l-header">
      <div class="l-inner clearfix">
        <div class="logo"><b class="a"></b><b class="b"></b>微职招聘 <i>随时随地挑好工作</i></div>
        <div class="logins">
          <div class="l-right" v-if="!isLogin">
            <a class="btn">求职者登录/注册</a>&emsp;
            <a class="btn cc" href="/company/login">企业登录/注册</a>&emsp;
          </div>
          <div class="l-right" v-if="isLogin"></div>
        </div>
      </div>
    </div>-->
    <!--导航-->
    <!--<div class="l-index-menu">
      <div class="l-inner">
        <a href="/home" class="cur">首页</a>
        <a>热门职位</a>
        <a>地图搜索</a>
        <a>人才库</a>
        <a href="/userCenter">个人中心</a>
      </div>
    </div>-->
    <div>
      <transition name="slideRight">
        <router-view></router-view>
      </transition>
    </div>
    <div class="l-footer">
        <div class="l-footer-main">
          <div class="l-inner">
            <span class="tit">常用链接:：</span>
            <span class="main">
              <a>企业招聘</a>
              <a>人才墙</a>
              <a>引凤还巢</a>
              <a>政府合作</a>
              <a>城市代理</a>
              <a>手机微职</a>
            </span>
            <div class="clear"></div>
            <span class="tit tit02">友情链接：</span>
            <span class="main main02">
              <a>重庆人才网</a>
              <a>教师联盟</a>
              <a>驾校</a>
              <a>企业招聘</a>
              <a>银行招聘网</a>
              <a>找工易</a>
              <a>装修网</a>
              <a>公司点评</a>
              <a>电力招聘网</a>
              <a>装修网</a>
              <a>中国人才热线</a>
              <a>东奥会计在线</a>
              <a>汇博人才网</a>
              <a>华尔街见闻</a>
              <a>培训网</a>
              <a>红黑联盟</a>
              <a>中国品牌网</a>
              <a>黄页</a>
              <a>中大网校</a>
              <a>中华考试网</a>
              <a>云南招聘网</a>
              <a>时尚家居</a>
              <a>时尚品牌网</a>
              <a>猎聘校园</a>
              <a>武汉美术网</a>
              <a>招聘网站</a>
              <a>职友集</a>
              <a>数字英才</a>
              <a>热门招聘信息</a>
              <a>事业单位招聘网</a>
              <a>天眼查</a>
              <a>职友集</a>
              <a>数字英才</a>
              培 ...
              <a>更多</a>
            </span>
            <div class="clear"></div>
          </div>
        </div>
        <div class="l-footer-bottom">Copyright ©201x-201x 微职网 鄂ICP备18013400号-2  黄石招才网</div>
    </div>
  </div>

</template>
<script>
  import { mapState, mapActions } from 'vuex';
  import { loginOut } from '@/service/web/login/loginService';
  import { district } from '@/service/company/selectService/selectMService';
  import { dictJopSearch, industry, companyScale, capitalStage } from '@/service/web/selectService/selectMService';
  export default {
    data () {
      return {
        isLogin: false,
        isLoginType: 0 // 1 官网用户 2 企业用户
      };
    },
    computed: {
      ...mapState([
        'userInfo',
        'companyUserInfo',
        'currentUserInfo'
      ])
    },
    async mounted () {
      // 判断是否登录
      let webToken = this._hyTool.getStore('webLoginInfo');
      let companyLoginInfo = this._hyTool.getStore('companyLoginInfo');
      if (webToken) {
        await this.getUserInfo();
        this.isLoginType = 1;
        this.isLogin = true;
      } else if (companyLoginInfo) {
        await this.getCompanyUserInfo();
        this.isLoginType = 2;
        this.isLogin = true;
      }
      await this.getDictionaries();
    },
    methods: {
      ...mapActions([
        'getUserInfo',
        'getCompanyUserInfo'
      ]),
      // 去登录
      toLogin () {
        this.$router.push({path: '/userSelect'});
      },
      // 去注册
      toRegister () {
        this.$router.push({path: '/userSelectRegister'});
      },
      toCompany () {
        this.$router.push({path: '/company'});
      },
      // 注销
      async loginOut () {
        this.$confirm('是否退出？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
          try {
            let webToken = this._hyTool.getStore('webLoginInfo');
            let companyLoginInfo = this._hyTool.getStore('companyLoginInfo');
            if (webToken) {
              await loginOut();
              this._hyTool.removeStore('webLoginInfo');
              this.$router.push('/home');
            } else if (companyLoginInfo) {
              this._hyTool.removeStore('companyLoginInfo');
              if (this.isLoginType === 1) this.$router.push('/home');
              if (this.isLoginType === 2) this.$router.push('/company');
            }
            this.$message({message: '注销成功', type: 'success'});
            this.isLogin = false;
          } catch (e) {
            this.isLogin = false;
          }
        }).catch(() => {
        });
      },
      // 跳转到个人中心、企业中心
      jumpCenter (type) {
        if (type === 1) {
          this.$router.push('/userCenter/resumeCenter');
        } else {
          this.$router.push('/company/main/home');
        }
      },
      // 加载字典表
      async getDictionaries () {
        let provinceData = await district({type: 1});
        this._hyTool.setStore('provinceData', provinceData.data);
        let cityData = await district({type: 10});
        this._hyTool.setStore('cityData', cityData.data);
        let jobListData = await dictJopSearch();
        this._hyTool.setStore('jobListData', jobListData.data);
        let industryListData = await industry();
        this._hyTool.setStore('industryListData', industryListData.data);
        let companyScaleData = await companyScale();
        this._hyTool.setStore('companyScaleData', companyScaleData.data);
        let capitalStageData = await capitalStage();
        this._hyTool.setStore('capitalStageData', capitalStageData.data);
      }
    }
  };
</script>
